﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Silverlight.Testing;
using Numbers;

namespace t_Numbers
{
    [TestClass]
    public class t_ValueTracker
    {
        [TestMethod]
        public void TestCtor()
        {
            Value v = new Value();
            ValueTracker t = new ValueTracker(v);
        }

        [TestMethod]
        public void TestMod()
        {
            Value v = new Value();
            ValueTracker t = new ValueTracker(v);

            Assert.AreEqual(0.0, t.Value, "initial value isn't zero!");
            v.Val = 5.0;
            Assert.AreEqual(5.0, t.Value, "Value didn't track!");
        }

        [TestMethod]
        public void TestInitialMethod()
        {
            Value v = new Value();
            v.Val = 10.0;
            ValueTracker t = new ValueTracker(v);

            Assert.AreEqual(10.0, t.Value, "Initial value not set correctly");
        }

        [TestMethod]
        public void TestChangeNotify()
        {
            string propChanged = "";
            Value v = new Value();
            ValueTracker t = new ValueTracker(v);
            t.PropertyChanged += (o, name) => propChanged = name.PropertyName;

            t.Name = "hi";
            Assert.AreEqual("Name", propChanged, "Expected Name to fire!");

            v.Val = 22.2;
            Assert.AreEqual("Value", propChanged, "Expected Value to fire!");
        }
    }
}